Merge "resourceloader: Move packaging to a new getModuleContent() method"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 9 Jun 2015 09:13:49 +0000 (09:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 9 Jun 2015 09:13:49 +0000 (09:13 +0000)
16 files changed:
RELEASE-NOTES-1.26
includes/Title.php
includes/logging/LogFormatter.php
includes/page/WikiPage.php
includes/parser/CacheTime.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderLanguageDataModule.php
includes/resourceloader/ResourceLoaderLanguageNamesModule.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/resourceloader/ResourceLoaderUserOptionsModule.php
tests/phpunit/ResourceLoaderTestCase.php
tests/phpunit/includes/logging/LogFormatterTestCase.php
tests/phpunit/includes/logging/MergeLogFormatterTest.php
tests/phpunit/includes/logging/NewUsersLogFormatterTest.php

index b55e23b..c862bf3 100644 (file)
@@ -59,6 +59,11 @@ changes to languages because of Bugzilla reports.
 * mediaWiki.confirmCloseWindow now returns an object of functions, instead of
   one function. The callback can't be called directly any more. The callback
   function is replaced with confirmCloseWindow.release().
+* BREAKING CHANGE: Added an optional ResouceLoaderContext parameter to
+  ResourceLoaderModule::getDependencies(). Extension classes that override that
+  method should be updated. If they aren't updated, PHP Strict standards
+  warnings will appear when E_STRICT error reporting is enabled. Note: in the
+  near future, this parameter will probably become non-optional.
 * Removed maintenance script deleteImageMemcached.php.
 * MWFunction::newObj() was removed (deprecated in 1.25).
   ObjectFactory::getObjectFromSpec() should be used instead.
index d5eff46..7aa4113 100644 (file)
@@ -4380,9 +4380,10 @@ class Title {
        /**
         * Updates page_touched for this page; called from LinksUpdate.php
         *
+        * @param integer $purgeTime TS_MW timestamp [optional]
         * @return bool True if the update succeeded
         */
-       public function invalidateCache() {
+       public function invalidateCache( $purgeTime = null ) {
                if ( wfReadOnly() ) {
                        return false;
                }
@@ -4394,11 +4395,13 @@ class Title {
                $method = __METHOD__;
                $dbw = wfGetDB( DB_MASTER );
                $conds = $this->pageCond();
-               $dbw->onTransactionIdle( function () use ( $dbw, $conds, $method ) {
+               $dbw->onTransactionIdle( function () use ( $dbw, $conds, $method, $purgeTime ) {
+                       $dbTimestamp = $dbw->timestamp( $purgeTime ?: time() );
+
                        $dbw->update(
                                'page',
-                               array( 'page_touched' => $dbw->timestamp() ),
-                               $conds,
+                               array( 'page_touched' => $dbTimestamp ),
+                               $conds + array( 'page_touched < ' . $dbw->addQuotes( $dbTimestamp ) ),
                                $method
                        );
                } );
index 119492b..0145b02 100644 (file)
@@ -790,7 +790,7 @@ class LogFormatter {
                                break;
 
                        case 'number':
-                               if ( ctype_digit( $value ) ) {
+                               if ( ctype_digit( $value ) || is_int( $value ) ) {
                                        $value = (int)$value;
                                } else {
                                        $value = (float)$value;
index abb22a0..5e72151 100644 (file)
@@ -1264,10 +1264,9 @@ class WikiPage implements Page, IDBAccessObject {
                        $conditions['page_latest'] = $lastRevision;
                }
 
-               $now = wfTimestampNow();
                $row = array( /* SET */
                        'page_latest'      => $revision->getId(),
-                       'page_touched'     => $dbw->timestamp( $now ),
+                       'page_touched'     => $dbw->timestamp( $revision->getTimestamp() ),
                        'page_is_new'      => ( $lastRevision === 0 ) ? 1 : 0,
                        'page_is_redirect' => $rt !== null ? 1 : 0,
                        'page_len'         => $len,
@@ -1865,7 +1864,7 @@ class WikiPage implements Page, IDBAccessObject {
                                $revision = null;
                                // Update page_touched, this is usually implicit in the page update
                                // Other cache updates are done in onArticleEdit()
-                               $this->mTitle->invalidateCache();
+                               $this->mTitle->invalidateCache( $now );
                        }
                } else {
                        // Create new article
@@ -2168,9 +2167,11 @@ class WikiPage implements Page, IDBAccessObject {
                        $editInfo = $this->mPreparedEdit;
                }
 
-               // Save it to the parser cache
+               // Save it to the parser cache.
+               // Make sure the cache time matches page_touched to avoid double parsing.
                ParserCache::singleton()->save(
-                       $editInfo->output, $this, $editInfo->popts, $editInfo->timestamp, $editInfo->revid
+                       $editInfo->output, $this, $editInfo->popts,
+                       $revision->getTimestamp(), $editInfo->revid
                );
 
                // Update the links tables and other secondary data
@@ -3159,7 +3160,6 @@ class WikiPage implements Page, IDBAccessObject {
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
-               $other->invalidateCache();
                $other->purgeSquid();
 
                $title->touchLinks();
@@ -3176,7 +3176,6 @@ class WikiPage implements Page, IDBAccessObject {
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
-               $other->invalidateCache();
                $other->purgeSquid();
 
                $title->touchLinks();
index 950c0d4..c450689 100644 (file)
@@ -47,7 +47,7 @@ class CacheTime {
        /**
         * setCacheTime() sets the timestamp expressing when the page has been rendered.
         * This does not control expiry, see updateCacheExpiry() for that!
-        * @param string $t
+        * @param string $t TS_MW timestamp
         * @return string
         */
        public function setCacheTime( $t ) {
index 0ee2e7d..e6c9bd0 100644 (file)
@@ -478,10 +478,10 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
 
        /**
         * Gets list of names of modules this module depends on.
-        *
+        * @param ResourceLoaderContext context
         * @return array List of module names
         */
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return $this->dependencies;
        }
 
index ebaf366..be15008 100644 (file)
@@ -71,9 +71,10 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
        }
 
        /**
+        * @param ResourceLoaderContext $context
         * @return array
         */
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return array( 'mediawiki.language.init' );
        }
 }
index 3111050..827a573 100644 (file)
@@ -60,7 +60,11 @@ class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule {
                );
        }
 
-       public function getDependencies() {
+       /**
+        * @param ResourceLoaderContext $context
+        * @return array
+        */
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return array( 'mediawiki.language.init' );
        }
 
index 8d4804c..874eb66 100644 (file)
@@ -333,9 +333,14 @@ abstract class ResourceLoaderModule {
         *
         * To add dependencies dynamically on the client side, use a custom
         * loader script, see getLoaderScript()
+        *
+        * Note: It is expected that $context will be made non-optional in the near
+        * future.
+        *
+        * @param ResourceLoaderContext $context
         * @return array List of module names as strings
         */
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                // Stub, override expected
                return array();
        }
index 5eb4e3a..03f2124 100644 (file)
@@ -62,9 +62,10 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
        }
 
        /**
+        * @param ResourceLoaderContext $context
         * @return array
         */
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return array( 'mediawiki.language' );
        }
 
index 6c078b0..8dbed8e 100644 (file)
@@ -226,7 +226,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
 
                        $registryData[$name] = array(
                                'version' => $versionHash,
-                               'dependencies' => $module->getDependencies(),
+                               'dependencies' => $module->getDependencies( $context ),
                                'group' => $module->getGroup(),
                                'source' => $module->getSource(),
                                'loader' => $module->getLoaderScript(),
index 4ed1b87..aba0fa6 100644 (file)
@@ -32,9 +32,10 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule {
        protected $targets = array( 'desktop', 'mobile' );
 
        /**
+        * @param ResourceLoaderContext $context
         * @return array List of module names as strings
         */
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return array( 'user.defaults' );
        }
 
index 6346bb9..223019c 100644 (file)
@@ -83,7 +83,7 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
                return array( '' => $this->styles );
        }
 
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return $this->dependencies;
        }
 
index e58711f..cab6794 100644 (file)
@@ -17,7 +17,7 @@ abstract class LogFormatterTestCase extends MediaWikiLangTestCase {
                        'Action text is equal to expected text'
                );
 
-               $this->assertEquals(
+               $this->assertSame( // ensure types and array key order
                        $extra['api'],
                        self::removeApiMetaData( $formatter->formatParametersForApi() ),
                        'Api log params is equal to expected array'
index 5a0b906..2ff0ddf 100644 (file)
@@ -25,9 +25,9 @@ class MergeLogFormatterTest extends LogFormatterTestCase {
                                array(
                                        'text' => 'User merged OldPage into NewPage (revisions up to 16:07, 4 August 2014)',
                                        'api' => array(
-                                               'mergepoint' => '2014-08-04T16:07:10Z',
                                                'dest_ns' => 0,
                                                'dest_title' => 'NewPage',
+                                               'mergepoint' => '2014-08-04T16:07:10Z',
                                        ),
                                ),
                        ),
@@ -49,9 +49,9 @@ class MergeLogFormatterTest extends LogFormatterTestCase {
                                        'legacy' => true,
                                        'text' => 'User merged OldPage into NewPage (revisions up to 16:07, 4 August 2014)',
                                        'api' => array(
-                                               'mergepoint' => '2014-08-04T16:07:10Z',
                                                'dest_ns' => 0,
                                                'dest_title' => 'NewPage',
+                                               'mergepoint' => '2014-08-04T16:07:10Z',
                                        ),
                                ),
                        ),
index 13dd839..5b03370 100644 (file)
@@ -71,7 +71,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'namespace' => NS_USER,
                                        'title' => 'New user',
                                        'params' => array(
-                                               '4::userid' => '1',
+                                               '4::userid' => 1,
                                        ),
                                ),
                                array(
@@ -109,7 +109,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'namespace' => NS_USER,
                                        'title' => 'UTSysop',
                                        'params' => array(
-                                               '4::userid' => '1',
+                                               '4::userid' => 1,
                                        ),
                                ),
                                array(
@@ -147,7 +147,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'namespace' => NS_USER,
                                        'title' => 'UTSysop',
                                        'params' => array(
-                                               '4::userid' => '1',
+                                               '4::userid' => 1,
                                        ),
                                ),
                                array(
@@ -185,7 +185,7 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'namespace' => NS_USER,
                                        'title' => 'New user',
                                        'params' => array(
-                                               '4::userid' => '1',
+                                               '4::userid' => 1,
                                        ),
                                ),
                                array(